/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.football.lottery.services;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.openide.util.Exceptions;

/**
 *
 * @author JingWen.Wen
 */
public class IOServices
{
  public void printBetList(List betList, int periodNo)
  {
    FileWriter fw = null;
    try
    {
      String filePath = "e:\\lottery\\" + periodNo;
      File file = new File(filePath);
      file.mkdirs();
      fw = new FileWriter(filePath + "\\" + periodNo + ".txt");
      Iterator it = betList.iterator();
      while (it.hasNext())
      {
        fw.write((String) it.next() + "\n");
      }
      fw.flush();
    }
    catch (IOException ex)
    {
      Exceptions.printStackTrace(ex);
    }
    finally
    {
      try
      {
        fw.close();
      }
      catch (IOException ex)
      {
        Exceptions.printStackTrace(ex);
      }
    }
  }
  
}
